package com.learning.mybatis.config.plugins;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.factory.DefaultObjectFactory;

import java.util.Collection;
import java.util.List;
import java.util.Properties;

/**
 * ClassName: CustomObjectFactory
 * Description:
 * Date: 2020/7/24 15:05 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Slf4j
public class CustomObjectFactory extends DefaultObjectFactory {

    @Override
    public <T> T create(Class<T> type) {
        log.debug("使用定制对象工厂 ObjectFactory 的create() 方法构建单个对象");
        return super.create(type);
    }

    @Override
    public <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
        log.debug("使用定制对象工厂 ObjectFactory 的create() 方法构建单个对象");
        return super.create(type, constructorArgTypes, constructorArgs);
    }

    @Override
    public void setProperties(Properties properties) {
        log.debug("定制属性：{}", properties);
        super.setProperties(properties);
    }

    @Override
    public <T> boolean isCollection(Class<T> type) {
        return Collection.class.isAssignableFrom(type);
    }
}
